package org.ccay.async.task;

import java.util.Date;

import org.ccay.core.base.BaseResourceVO;

/**
 * VO for import tasks
 * 
 * @author chaowangbang
 * @since 2012-2-17
 */
public class ImportTaskVO extends BaseResourceVO {
	/**
	 * 
	 */
	private static final long serialVersionUID = 164568504575116845L;

	/** 由毫秒得出秒* */
	private static final int SECOND = 1000;

	/** 任务 ID* */
	private int taskId;

	/** 任务 号* */
	private String taskNo;

	/** 类型 * */
	private String typeId;

	/** 导入状态[0:waiting;1:generating;2:completion;3:Partial Succeed(hkf16418 把状态Canceled改为部分成功);4:Exception;] * */
	private String importStatus;

	/** 导入状态描述* */
	private String importStatusDesc;

	/** 任务数量* */
	private Integer operateQty = 0;

	/** 已导入数量* */
	private Integer importedQty = 0;

	/** 备注* */
	private String remark;

	/** 客户端文件名* */
	private String displayFileName;
	
	/** 文件路径* */
	private String filePath;

	private String dealStatus;


	/** 后台导入错误信息* */
	private String errorMsg;

	/** 查询的开始时间* */
	private Date taskDateFrom;

	/** 查询的结束时间* */
	private Date taskDateTo;

	/** 任务类型* */
	private String taskType;

	/** 查看编辑url连接(控制台的view task)* */
	private String viewTaskUrl;

	/** 验证错误回写文件名* */
	private String valiErrorFile;

	/** 导入文件大小* */
	private Long fileSize;

	/** 导入运行开始时间* */
	private Date runStartTime;

	/** 导入运行结束时间* */
	private Date runEndTime;

	/** 导入运行总时间 单位：s[秒]* */
	private Integer consumeTime;

	private String tableName;

	/** 导入任务创建者 * */
	private String owner;

	/** 导入时使用的参数，使用JSON格式保存 */
	private String parameters;
	
	/** 跨应用保存绝对路径 * */
	private String downloadUrl;
	
	
	public String getDownloadUrl() {
		return downloadUrl;
	}

	public void setDownloadUrl(String downloadUrl) {
		this.downloadUrl = downloadUrl;
	}

	/**
	 * @return the dealStatus
	 */
	public String getDealStatus() {
		return dealStatus;
	}

	/**
	 * @param dealStatus
	 *            the dealStatus to set
	 */
	public void setDealStatus(String dealStatus) {
		this.dealStatus = dealStatus;
	}

	/**
	 * @return the errorMsg
	 */
	public String getErrorMsg() {
		return errorMsg;
	}

	/**
	 * @param errorMsg
	 *            the errorMsg to set
	 */
	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	/**
	 * @return the fileName
	 */
	public String getDisplayFileName() {
		return displayFileName;
	}

	/**
	 * @param fileName
	 *            the fileName to set
	 */
	public void setDisplayFileName(String fileName) {
		this.displayFileName = fileName;
	}

	/**
	 * @return the fileSize
	 */
	public Long getFileSize() {
		return fileSize;
	}

	/**
	 * @param fileSize
	 *            the fileSize to set
	 */
	public void setFileSize(Long fileSize) {
		this.fileSize = fileSize;
	}

	/**
	 * @return the importedQty
	 */
	public Integer getImportedQty() {
		return importedQty;
	}

	/**
	 * @param importedQty
	 *            the importedQty to set
	 */
	public void setImportedQty(Integer importedQty) {
		this.importedQty = importedQty;
	}

	/**
	 * @return the importStatus
	 */
	public String getImportStatus() {
		return importStatus;
	}

	/**
	 * @param importStatus
	 *            the importStatus to set
	 */
	public void setImportStatus(String importStatus) {
		this.importStatus = importStatus;
	}

	/**
	 * @return the importStatusDesc
	 */
	public String getImportStatusDesc() {
		return importStatusDesc;
	}

	/**
	 * @param importStatusDesc
	 *            the importStatusDesc to set
	 */
	public void setImportStatusDesc(String importStatusDesc) {
		this.importStatusDesc = importStatusDesc;
	}

	/**
	 * @return the operateQty
	 */
	public Integer getOperateQty() {
		return operateQty;
	}

	/**
	 * @param operateQty
	 *            the operateQty to set
	 */
	public void setOperateQty(Integer operateQty) {
		this.operateQty = operateQty;
	}

	/**
	 * @return the remark
	 */
	public String getRemark() {
		return remark;
	}

	/**
	 * @param remark
	 *            the remark to set
	 */
	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * @return the runEndTime
	 */
	public Date getRunEndTime() {
		return runEndTime;
	}

	/**
	 * @param runEndTime
	 *            the runEndTime to set
	 */
	public void setRunEndTime(Date runEndTime) {
		this.runEndTime = runEndTime;
	}

	/**
	 * @return the runStartTime
	 */
	public Date getRunStartTime() {
		return runStartTime;
	}

	/**
	 * @param runStartTime
	 *            the runStartTime to set
	 */
	public void setRunStartTime(Date runStartTime) {
		this.runStartTime = runStartTime;
	}


	/**
	 * @return the tableName
	 */
	public String getTableName() {
		return tableName;
	}

	/**
	 * @param tableName
	 *            the tableName to set
	 */
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	/**
	 * @return the taskDateFrom
	 */
	public Date getTaskDateFrom() {
		return taskDateFrom;
	}

	/**
	 * @param taskDateFrom
	 *            the taskDateFrom to set
	 */
	public void setTaskDateFrom(Date taskDateFrom) {
		this.taskDateFrom = taskDateFrom;
	}

	/**
	 * @return the taskDateTo
	 */
	public Date getTaskDateTo() {
		return taskDateTo;
	}

	/**
	 * @param taskDateTo
	 *            the taskDateTo to set
	 */
	public void setTaskDateTo(Date taskDateTo) {
		this.taskDateTo = taskDateTo;
	}

	/**
	 * @return the taskId
	 */
	public int getTaskId() {
		return taskId;
	}

	/**
	 * @param taskId
	 *            the taskId to set
	 */
	public void setTaskId(int taskId) {
		this.taskId = taskId;
	}

	/**
	 * @return the taskNo
	 */
	public String getTaskNo() {
		return taskNo;
	}

	/**
	 * @param taskNo
	 *            the taskNo to set
	 */
	public void setTaskNo(String taskNo) {
		this.taskNo = taskNo;
	}

	/**
	 * @return the taskType
	 */
	public String getTaskType() {
		return taskType;
	}

	/**
	 * @param taskType
	 *            the taskType to set
	 */
	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	/**
	 * @return the totalTime
	 */
	public Integer getConsumeTime() {
		if (runStartTime == null || runEndTime == null) {
			consumeTime = 0;
		} else {
			consumeTime = (int) ((runEndTime.getTime() - runStartTime.getTime())/ SECOND);
		}
		return consumeTime;
	}

	/**
	 * @param totalTime
	 *            the totalTime to set
	 */
	public void setConsumeTime(Integer consumeTime) {
		this.consumeTime = consumeTime;
	}

	/**
	 * @return the typeId
	 */
	public String getTypeId() {
		return typeId;
	}

	/**
	 * @param typeId
	 *            the typeId to set
	 */
	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}

	/**
	 * @return the valiErrorFile
	 */
	public String getValiErrorFile() {
		return valiErrorFile;
	}

	/**
	 * @param valiErrorFile
	 *            the valiErrorFile to set
	 */
	public void setValiErrorFile(String valiErrorFile) {
		this.valiErrorFile = valiErrorFile;
	}

	/**
	 * @return the viewTaskUrl
	 */
	public String getViewTaskUrl() {
		return viewTaskUrl;
	}

	/**
	 * @param viewTaskUrl
	 *            the viewTaskUrl to set
	 */
	public void setViewTaskUrl(String viewTaskUrl) {
		this.viewTaskUrl = viewTaskUrl;
	}

	/**
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}

	/**
	 * @param owner
	 *            the owner to set
	 */
	public void setOwner(String owner) {
		this.owner = owner;
	}

	public Integer getFailedQty() {
//		if(StringUtil.isNullOrEmpty(this.operateQty)){
//			return "0";
//		}
//		if(StringUtil.isNullOrEmpty(this.importedQty)){
//			return this.operateQty;
//		}
		return this.operateQty - this.importedQty;
	}

	public String getParameters() {
		return parameters;
	}

	public void setParameters(String parameters) {
		this.parameters = parameters;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

}
